﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace OptiGear1
{
    public partial class SaveProfileForm : Form
    {
        private Form1 form1;
        public SaveProfileForm(Form1 form1)
        {
            this.form1 = form1;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (profileNameText.Text.Trim().Length == 0)
            {
                MessageBox.Show("Name cannot be blank");
                return;
            }

            Regex objAlphaNumericPattern=new Regex("[^a-zA-Z0-9]");
            if (objAlphaNumericPattern.IsMatch(profileNameText.Text))
            {
                MessageBox.Show("Alphanumeric characters only");
                return;
            }

            form1.SaveNewProfile(profileNameText.Text);
            this.Close();
        }
    }
}
